from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QLineEdit,QVBoxLayout,QTextEdit
import sys

def init_widget(w:QWidget):
    #  创建垂直布局
    layout = QVBoxLayout()
    
    edit = QLineEdit()
    edit.setPlaceholderText("请输入内容")
    edit.setPlaceholderText("请输入用户名")
    edit.setMaxLength(20)
    layout.addWidget(edit)
    
    edit_pwd = QLineEdit()
    edit_pwd.setEchoMode(QLineEdit.Password)
    edit_pwd.setPlaceholderText("请输入密码")
    layout.addWidget(edit_pwd) 
    
    text_edit = QTextEdit()
    text_edit.setPlaceholderText("请输入个人介绍")
    text_edit.setPlainText("我是XXX,我来自XXX")
    
    text_edit.setHtml("<b>我是XXX,我来自XXX</b>")
    print(text_edit.toPlainText())
    layout.addWidget(text_edit)
    
    print("password",edit.text())
    w.setLayout(layout) 

if __name__ == '__main__':

    
    # 创建应用程序
    app = QApplication(sys.argv)
    
    # 创建窗口

    w = QWidget()
    #设置窗口标题
    w.setWindowTitle("单行输入框")
    init_widget(w)
    

    #显示窗口
    #提交  
    w.show()

    #等待窗口停止
    sys.exit(app.exec())